<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<base href="${pageContext.request.scheme }://${pageContext.request.serverName}:
${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
<html>
<head>
<meta charset="UTF-8">
<title>用户管理</title>
<link type="text/css" rel="stylesheet" href="static/css/style.css" >
<style type="text/css">
li{list-style: none}
</style>
</head>
<body>
<h3>pageNo:${page.pageNo}</h3>
	<div id="header">
			<span class="wel_word">用户管理系统</span>
			<div>
				<span style="color: coral">【${msg}】</span>
				${pageContext.session.removeAttribute("msg")}
				<a href="manager.jsp">返回主页</a>
				<a href="UserServlet?way=doLogout">退出</a>
			</div>
	</div>
	<div id="main">
		<table>
			<tr>
				<td>用户名</td>
				<td>密码</td>
				<td>邮箱</td>
				<td>手机号</td>
				<td colspan="2">操作</td>
			</tr>

<%--			items:servlet传来的UserLIst--%>
			<c:forEach items="${page.list}" var="user" >
				<tr>
					<td>${user.username}</td>
					<td>${user.password}</td>
					<td>${user.email}</td>
					<td>18888888888</td>
					<td><a href="UserServlet?way=getUserById&id=${user.id}&pageNo=${page.pageNo}">修改</a></td>
<%--					<td><a href="UserServlet?way=deleteUserById&id=${user.id}&pageNo=${page.pageNo}&username=${user.username}">删除</a></td>--%>
					<td><a href="JavaScript:void(0)" onclick="deleteUserById(${user.id},'${user.username}')">删除</a></td>
				</tr>
				<script>
					function deleteUserById(id,username) {
						if(confirm("你确定要删除"+"【"+username+"】吗？")){
							window.location.href="UserServlet?way=deleteUserById&id="+id+"&username="+username+"&pageNo="+${page.pageNo};
						}
					}
				</script>
			</c:forEach>

			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td><a href="UserServlet?way=getUserById&id=null&pageNo=${page.totalPageNo}">添加用户</a></td>

			</tr>

		</table>
		<div id="page_nav">

			<c:if test="${page.pageNo<=1}">
				<a href="JavaScript:void(0)">首页</a>
				<a href="JavaScript:void(0)">上一页</a>
			</c:if>
			<c:if test="${page.pageNo>1}">
				<a style="color: blue" href="UserServlet?way=getUserList&pageno=1">首页</a>
				<a style="color: blue" href="UserServlet?way=getUserList&pageno=${page.pageNo-1}">上一页</a>
			</c:if>

			<c:if test="${page.pageNo>=page.totalPageNo}">
				<a href="JavaScript:void(0)">下一页</a>
				<a href="JavaScript:void(0)">末页</a>
			</c:if>
			<c:if test="${page.pageNo<page.totalPageNo}">
				<a style="color: blue" href="UserServlet?way=getUserList&pageno=${page.pageNo+1}">下一页</a>
				<a style="color: blue" href="UserServlet?way=getUserList&pageno=${page.totalPageNo}">末页</a>
			</c:if>
			<span>当前页码：${page.pageNo}|||总页码：${page.totalPageNo}</span>
		</div>
	</div>
	
	<div id="bottom">
		<span>
			中公用户管理.Copyright &copy;2019
		</span>
	</div>
</body>
</html>